package com.example.jingwei.tian.nativeh5test;

import android.content.Context;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.widget.Toast;

/**
 * Created by tian.jingwei on 2018/3/28.
 */

public class MWebChromeClient extends WebChromeClient {
    private Context mContext;

    public MWebChromeClient(Context context) {
        mContext = context;
    }

    /**
     * JS调用Android(Java)无参数的方法
     */
    @JavascriptInterface
    public void jsCallWebView() {
        Toast.makeText(mContext, "JS Call Java!", Toast.LENGTH_SHORT).show();
    }

    /**
     * JS调用Android(Java)含参数的方法
     * @param param
     */
    @JavascriptInterface
    public void jsCallWebView(String param) {
        Toast.makeText(mContext, "JS Call Java!" + param, Toast.LENGTH_SHORT).show();
    }
}
